#include <iostream>
using std::cout;
using std::endl;

class Point
{
public:
    Point(int ix,int iy)
    : _ix(ix)
    , _iy(iy)
    {}

    void print() const{
        cout << "(" << _ix
            << "," << _iy 
            << ")" << endl;
    }

    Point & operator+=(const Point & rhs){
        cout << "+=重载函数" << endl;
        _ix += rhs._ix;
        _iy += rhs._iy;
        return *this;
    }
    
    Point & operator++(){
        cout << "前置++重载函数" << endl;
        ++_ix;
        ++_iy;
        return *this;
    }

    Point operator++(int){
        cout << "后置++重载函数" << endl;
        Point temp(*this);
        ++_ix;
        ++_iy;
        return temp;
    }


    friend
    Point operator+(const Point & lhs,const Point & rhs);
private:
    int _ix;
    int _iy;
};

Point operator+(const Point & lhs,const Point & rhs){
    cout << "+重载函数" << endl;
    return Point(lhs._ix + rhs._ix, lhs._iy + rhs._iy);
}

void test0(){
    Point pt1(1,2);
    Point pt2(3,4);
    pt1 += pt2;
    pt1.print();

    cout << endl;
    (++pt1).print();

    cout << endl;
    (pt1++).print();
    pt1.print();
}



int main(void){
    test0();
    return 0;
}
